package com.sky.zero.common.generate.core;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 全局配置
 *
 * @author hetao
 * @ClassName: GenerateConfig
 * @Description:
 * @date 2017年8月26日 下午11:42:15
 */
public class GenerateConfig {

    /**
     * 数据库配置
     **/
    public static String jdbcDriver = "com.mysql.cj.jdbc.Driver";
    public static String jdbcUrl;
    public static String jdbcUserName;
    public static String jdbcPassword;

    /**
     * 数据类型配置
     **/
    public static Map<String, String> dataTypeMap = new HashMap<String, String>();

    /**
     * 导包配置
     **/
    public static Map<String, String> importMap = new LinkedHashMap<String, String>();

    /**
     * 是否覆盖现有文件 默认 false 不覆盖
     **/
    public static boolean isCoverage = false;

    public GenerateConfig() {
        /** 数据类型配置 **/
        dataTypeMap.put("bigint", "Long");
        dataTypeMap.put("varchar", "String");
        dataTypeMap.put("char", "String");
        dataTypeMap.put("int", "Integer");
        dataTypeMap.put("tinyint", "Integer");
        dataTypeMap.put("Date", "Date");
        dataTypeMap.put("text", "String");
        dataTypeMap.put("decimal", "BigDecimal");
        dataTypeMap.put("mediumtext", "String");
        dataTypeMap.put("varbinary", "String");
        dataTypeMap.put("datetime", "Date");
        dataTypeMap.put("date", "Date");

        /** 导包配置 **/
        // 内部包
        importMap.put("BaseController", "import com.sky.zero.common.generate.core.base.BaseController;\n");
        importMap.put("BaseService", "import com.sky.zero.common.generate.core.base.BaseService;\n");
        importMap.put("BaseEntity", "import com.sky.zero.common.generate.core.base.BaseEntity;\n");
        importMap.put("Results", "import com.sky.zero.common.generate.core.base.ResponseVO;\n");
        importMap.put("BaseMapper<", "import com.sky.zero.common.generate.core.base.BaseMapper;\n");

        // Java包
        importMap.put("private Date", "import java.util.Date;\n");
        importMap.put("private BigDecimal", "import java.math.BigDecimal;\n");
        importMap.put("private Timestamp", "import java.sql.Timestamp;\n");
        importMap.put("implements Serializable", "import java.io.Serializable;\n");
        importMap.put("List<", "import java.util.List;\n");
        importMap.put("Collections.singletonList", "import java.util.Collections;\n");
        // Spring 包
        importMap.put("@Service", "import org.springframework.stereotype.Service;\n");
        importMap.put("@Autowired", "import org.springframework.beans.factory.annotation.Autowired;\n");
        importMap.put("@Transactional", "import org.springframework.transaction.annotation.Transactional;\n");
        importMap.put("@Controller", "import org.springframework.stereotype.Controller;\n");
        importMap.put("@RestController", "import org.springframework.web.bind.annotation.RestController;\n");
        importMap.put("@RequestMapping", "import org.springframework.web.bind.annotation.RequestMapping;\n");
        importMap.put("RequestMethod", "import org.springframework.web.bind.annotation.RequestMethod;\n");
        importMap.put("@CacheConfig", "import org.springframework.cache.annotation.CacheConfig;\n");
        importMap.put("@RequestBody", "import org.springframework.web.bind.annotation.RequestBody;\n");
        importMap.put("@RequestParam", "import org.springframework.web.bind.annotation.RequestParam;\n");
        importMap.put("@Cacheable", "import org.springframework.cache.annotation.Cacheable;\n");
        importMap.put("@CacheEvict", "import org.springframework.cache.annotation.CacheEvict;\n");
        // javax 包
        importMap.put("@Column", "import javax.persistence.Column;\n");
        importMap.put("@Id", "import javax.persistence.Id;\n");
        importMap.put("@Table", "import javax.persistence.Table;\n");
        importMap.put("@NotNull", "import javax.validation.constraints.NotNull;\n");
        // apache 包
        importMap.put("@Select", "import org.apache.ibatis.annotations.Select;\n");
        // jackson 包
        importMap.put("@JsonFormat", "import com.fasterxml.jackson.annotation.JsonFormat;\n");
        importMap.put("Shape.STRING", "import com.fasterxml.jackson.annotation.JsonFormat.Shape;\n");
        // slf4j 包
        importMap.put("LoggerFactory.getLogger", "import org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n");
        // lombok 包
        importMap.put("@Getter", "import lombok.Getter;\n");
        importMap.put("@Setter", "import lombok.Setter;\n");
        importMap.put("@ToString", "import lombok.ToString;\n");
        importMap.put("@NoArgsConstructor", "import lombok.NoArgsConstructor;\n");
        importMap.put("@Slf4j", "import lombok.extern.slf4j.Slf4j;\n");
        //dubbo 包
        importMap.put("@DubboService", "import org.apache.dubbo.config.annotation.DubboService;\n");

        // PageInfo
        importMap.put("PageInfo<", "import com.github.pagehelper.PageInfo;\n");

        //hutool 包
        importMap.put("BeanUtil.", "import cn.hutool.core.bean.BeanUtil;\n");
    }

}
